﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;
using QuanLyKhachSan.report;
namespace QuanLyKhachSan.BaoCao
{
    public partial class frmBaoCaoXuatNhapTon : DevExpress.XtraEditors.XtraForm
    {
        DataClassesKhachSanDataContext db = new DataClassesKhachSanDataContext(SystemInfo.pub_ConnString); 
        public frmBaoCaoXuatNhapTon()
        {
            InitializeComponent();
        }

        private void btBaoCao_Click(object sender, EventArgs e)
        {
            this.fillData();
        }
        void fillData()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("dt_id" , typeof (Int16));
            dt.Columns.Add("dt_ten");
            dt.Columns.Add("dt_dvi");
            dt.Columns.Add("dt_dongia", typeof(Decimal ));
            dt.Columns.Add("nhap", typeof(Int16));
            dt.Columns.Add("xuat", typeof(Int16));
            dt.Columns.Add("ton", typeof(Int16));

            var ton = db.XuatNhapTon( Convert.ToDateTime (dateEdit1.EditValue)).ToList ();
            for (int i = 0; i < ton.Count; i++)
            {
                dt.Rows.Add(
                    ton[i].dt_ID,
                    ton[i].dt_TEN,
                    ton[i].DT_DVI,
                    ton[i].DT_DONGIA,
                    ton[i].NHAP,
                    ton[i].XUAT,
                    ton[i].TON
                    ); 
            }

            rptTonkho tonkho = new rptTonkho();
            tonkho.SetDataSource(dt);
            crystalReportViewer1.ReportSource = tonkho; 
        }

        private void frmBaoCaoXuatNhapTon_Load(object sender, EventArgs e)
        {

        }
    }
}